﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
 }
 <div class="layuimini-container">
     <div class="layuimini-main">
         <fieldset class="table-search-fieldset layui-hide" id="searchField">
             <div>
                 <form class="layui-form layui-form-pane" >
                     <div class="layui-form-item">
                         <div class="layui-inline">
                             <label class="layui-form-label required">日期:</label>
                             <div class="layui-input-block">
                                 <select id="time_horizon" name="time_horizon" lay-verify="required">
                                     <option value="1">今天</option>
                                     <option value="2" selected>近7天</option>
                                     <option value="3">近1个月</option>
                                     <option value="4">近2个月</option>
                                 </select>
                             </div>
                         </div>
                         <div class="layui-inline">
                             <label class="layui-form-label">关键字:</label>
                             <div class="layui-input-inline">
                                 <input type="text" id="txt_keyword" name="txt_keyword" autocomplete="off" class="layui-input">
                             </div>
                         </div>
                         <div class="layui-inline">
                             <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon">&#xe615;</i> 搜 索</button>
                         </div>
                     </div>
                 </form>
             </div>
         </fieldset>
         <script type="text/html" id="toolbarDemo">
             <div class="layui-btn-container" id="toolbar">
             </div>
         </script>
         <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
     </div>
 </div>
 <script>
     layui.use(['jquery', 'form','table','commonTable', 'common','optimizeSelectOption'], function () {
         var $ = layui.jquery,
             form = layui.form,
             table = layui.table,commonTable = layui.commonTable
             common = layui.common;
         //权限控制(js是值传递)
         toolbarDemo.innerHTML = common.authorizeButtonNew(toolbarDemo.innerHTML);
         commonTable.rendertable({
             elem: '#currentTableId',
             id: 'currentTableId',
             url: '/QualityManage/ScapMaterialReturn/GetGridJson',
             filter: {
                 clearFilter: false,
                 //数据量大，data就不需要了
                 items: ['column', 'condition', 'editCondition', 'excel']
             },
             totalRow: true,
             cols: [[
                 { field: 'F_BatchCode', title: '条码编号', width: 170, sort: true, filter: true },
                 { field: 'F_TransferBoxCode', title: '退回流转箱编号', width: 170, sort: true, filter: true },
                 { field: 'F_BackMaterialBatch', title: '退回批号', width: 170, sort: true, filter: true, totalRowText: '合计:' },
                 { field: 'F_Num', title: '数量', width: 110, sort: true, filter: true, totalRow: true },
                 { field: 'F_MaterialCode', title: '料号编号', width: 170, sort: true, filter: true },
                 { field: 'F_MaterialName', title: '料号名称', width: 200, sort: true, filter: true },
                 {
                     field: 'F_MaterialType', title: '料号分类', width: 105, sort: true, filter: true,
                     templet: function (d) {
                         return top.clients.dataItems["Mes_MaterialType"][d.F_MaterialType] == null ? "" : top.clients.dataItems["Mes_MaterialType"][d.F_MaterialType];
                     }
                 },
                 { field: 'F_MaterialBatch', title: '批号', width: 180, sort: true, filter: true },
                 {
                     field: 'F_CreatorTime', title: '退回时间', width: 160, sort: true, filter: { type: 'date[yyyy/MM/dd HH:mm:ss]' }
                 },
                 { field: 'F_CreatorUserName', title: '退回人', width: 110,sort: true,filter: true }
             ]]
         });
         // 监听搜索操作
         form.on('submit(data-search-btn)', function (data) {
             //执行搜索重载
             commonTable.reloadtable({
                 elem: 'currentTableId',
                 curr: 1,
                 where: { timetype: data.field.time_horizon, keyword: data.field.txt_keyword }
             });
             return false;
         });
         wcLoading.close();
         //toolbar监听事件
         table.on('toolbar(currentTableFilter)', function (obj) { 
             var data = table.checkStatus('currentTableId').data;
             var id = data.length > 0 ? data[0].F_Id : null;
             if (obj.event === 'TABLE_SEARCH') {
                var _that = $("#searchField");
                if (_that.hasClass("layui-hide")) {
                   _that.removeClass('layui-hide');
                } else {
                   _that.addClass('layui-hide');
                }
           }
           return false;
       });
   });
</script>
